package com.ruoyi.system.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.EnterpriseMaterial;
import com.ruoyi.system.service.IEnterpriseMaterialService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 企业物料库存Controller
 *
 * @author 协同
 * @date 2022-04-20
 */
@RestController
@RequestMapping("/system/enterpriseMaterial")
public class EnterpriseMaterialController extends BaseController {
    @Autowired
    private IEnterpriseMaterialService enterpriseMaterialService;

    /**
     * 查询企业物料库存列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EnterpriseMaterial enterpriseMaterial) {
        startPage();
        List<EnterpriseMaterial> list = enterpriseMaterialService.selectEnterpriseMaterialList(enterpriseMaterial);
        return getDataTable(list);
    }

    /**
     * 获取企业物料库存详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(enterpriseMaterialService.selectEnterpriseMaterialById(id));
    }

    /**
     * 新增企业物料库存
     */
    @PostMapping
    public AjaxResult add(@RequestBody EnterpriseMaterial enterpriseMaterial) {
        return toAjax(enterpriseMaterialService.insertEnterpriseMaterial(enterpriseMaterial));
    }

    /**
     * 修改企业物料库存
     */
    @PutMapping
    public AjaxResult edit(@RequestBody EnterpriseMaterial enterpriseMaterial) {
        return toAjax(enterpriseMaterialService.updateEnterpriseMaterial(enterpriseMaterial));
    }

    /**
     * 删除企业物料库存
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(enterpriseMaterialService.deleteEnterpriseMaterialByIds(ids));
    }
}
